let isNodeEnv = false;
if (typeof window === 'undefined') {
    window = global;
    isNodeEnv = true;
}
let genUUID = function () {
    if (isNodeEnv || window.AVG_EDITOR) {
        return require('uuid/v4')();
    } else {
        function _p8 (s) {
            var p = (Math.random().toString(16) + '000000000').substr(2, 8);
            return s ? '-' + p.substr(0, 4) + '-' + p.substr(4, 4) : p;
        }

        return _p8() + _p8(true) + _p8(true) + _p8();
    }
};

const AvgType = {
    Test: {
        type: 'test', // 配置文件保存的id
    },
    Root: {
        type: 'piece',
    }, // 根节点
    HelperInsertScene: {
        type: 'helper-insert-scene',
    },
    HelperInsertRole: {
        type: 'helper-insert-role',
    },
    ImageBg: {
        type: 'image-bg',
    },
    ImageItem: {
        type: 'image-item',
    },
    ImageDraw: {
        type: 'image-draw',
    },
    ImageHead: {
        type: 'image-head',
    },
    Effect: {
        type: 'effect',
    }, // 粒子特效
    EffectRain: {
        type: 'effect-rain',
    },
    EffectWin: {
        type: 'effect-win',
    },
    EffectSnow: {
        type: 'effect-snow',
    },
    EffectLight: {
        type: 'effect-light',
    },
    EffectBloodDrip: {
        type: 'effect-blood-drip',
    },
    EffectFog: {
        type: 'effect-fog',
    },
    EffectBoom: {
        type: 'effect-boom',
    },
    EffectLeafFall: {
        type: 'effect-leafFall',
    },
    EffectBloodDown: {
        type: 'effect-blood-down',
    },
    EffectFire: {
        type: 'effect-fire',
    },
    EffectSpotFire: {
        type: 'effect-spot-fire',
    },
    PlotMenu: {
        type: 'plot-menu',
        sub: {
            limit: 'limit',
            menu: 'menu',
        },
    }, // 剧情选项
    PlotJump: {
        type: 'plot-jump',
    }, // 剧情跳转
    ValueJudge: {
        type: 'value-judge',
    }, // 数值判断器
    PasswordLock: {
        type: 'password-lock',
    },
    QTE: {
        type: 'qte',
        sub: {
            tips: 'tips', // 提示文本
            graphics: 'graphics', // 计时图形
        },
    },
    Talk: {
        type: 'talk',
        sub: {
            head: 'head', // 人物头像
            name: 'name', // 人物名字
            text: 'text', // 对话文字
            panel: 'panel', // 对话面板
        },
    }, // 对话
    Text: {
        type: 'text',
    },
    AudioBgStopGlobal: {
        type: 'audio-bg-stop-global',
    },
    AudioBg: {
        type: 'audio-bg',
    }, // 背景音乐
    AudioEffect: {
        type: 'audio-effect',
    }, // 音效
    AudioAside: {
        type: 'audio-aside',
    },
    VideoPlot: {
        type: 'video-plot',
    },
    UiCover: {
        type: 'ui-cover',
    },
    UiEnv: {
        type: 'ui-env',
    },
    UiFileMgr: {
        type: 'ui-file-mgr',
    },
    UiMenu: {
        type: 'ui-menu',
    },
};

const TimelineType = {
    Element: {
        name: '元素',
        type: 'element',
    },
    Audio: {
        name: '声音',
        type: 'audio',
    },
    StopGlobalAudio: {
        name: '停止全局背景音乐',
        type: 'stop-global-audio',
    },
    Effect: {
        name: '特效',
        type: 'effect',
    },
};
const FontType = {
    Font0: {
        name: '默认',
        font: 'arial',
    },
    Font1: {
        name: '华康圆体',
        font: 'font1',
    },
    Font2: {
        name: '华康少女体',
        font: 'font2',
    },
    Font3: {
        name: '华康翩翩体',
        font: 'font3',
    },
    Font4: {
        name: '庞门正道标题体',
        font: 'font4',
    },
    Font5: {
        name: '站酷快乐体',
        font: 'font5',
    },
    Font6: {
        name: '竹石体',
        font: 'font6',
    },
};
const ActionType = {
    None: {
        name: '无',
        type: 'none',
    },
    FadeIn: {
        name: '淡入',
        type: 'fade-in',
    },
    FadeOut: {
        name: '淡出',
        type: 'fade-out',
    },
    Move: {
        name: '移动',
        type: 'move',
    },
    Shake: {
        name: '震动',
        type: 'shake',
    },
    Scale: {
        name: '缩放',
        type: 'scale',
    },
    Rotation: {
        name: '旋转',
        type: 'rotation',
    },
    Blur: {
        name: '模糊',
        type: 'blur',
    },
};
const ActionAudioType = {
    Play: {
        name: '播放',
        type: 'play',
    },
};
const ActionVideoType = {
    Play: {
        name: '播放',
        type: 'play',
    },
    FadeIn: ActionType.FadeIn,
    FadeOut: ActionType.FadeOut,
    Move: ActionType.Move,
    Shake: ActionType.Shake,
    Scale: ActionType.Scale,
};
const ShakeStrength = {
    low: {
        name: '弱',
        type: 'low',
    },
    lower: {
        name: '较弱',
        type: 'lower',
    },
    normal: {
        name: '中',
        type: 'normal',
    },
    higher: {
        name: '较强',
        type: 'higher',
    },
    high: {
        name: '强',
        type: 'high',
    },
};
const startingMoment = {
    afterPrevious: {
        name: '上个动作之后',
        type: 'afterPrevious',
    },
    asPrevious: {
        name: '上个动作同时',
        type: 'asPrevious',
    },
    manual: {
        name: '玩家触发',
        type: 'manual',
    },
    direct: {
        name: '直接播放',
        type: 'direct',
    },
};
const EffectCfg = {
    com: {
        // 光束
        light: {
            style1: 'effect/light/light - 001',
            style2: 'effect/light/light - 002',
            style3: 'effect/light/light - 003',
        },
        // 溅血
        bloodDrip: {
            less: 'effect/bloodDrip/bloodDrip01',
            middle: 'effect/bloodDrip/bloodDrip02',
            more: 'effect/bloodDrip/bloodDrip03',
        },
        // 火焰
        fire: {
            less: 'effect/fire/fire01/fire01',
            middle: 'effect/fire/fireBig01/fireBig01',
            more: 'effect/fire/fireWall/fireWall',
        },
        // 雾
        fog: {
            fast: 'effect/fog/fogFast',
            slow: 'effect/fog/fogSlow',
            common: 'effect/fog/fogCommon',
        },

        // 雨
        rain: {
            down: {
                small: 'effect/rainFall/rainFallSmall',
                big: 'effect/rainFall/rainFallBig',
                middle: 'effect/rainFall/rainFallMiddle',
            },
            right: {
                small: 'effect/rainFall/rainFallSmallLeft',
                big: 'effect/rainFall/rainFallBigLeft',
                middle: 'effect/rainFall/rainFallMiddleLeft',
            },
            left: {
                small: 'effect/rainFall/rainFallSmallRight',
                big: 'effect/rainFall/rainFallBigRight',
                middle: 'effect/rainFall/rainFallMiddleRight',
            },
        },
        // 落叶
        leaf: {
            less: 'effect/leafFall/leafFallLess/leafFallLess',
            middle: 'effect/leafFall/leafFallMiddle/leafFallMiddle',
            more: 'effect/leafFall/leafFallMore/leafFallMore',
        },
        // 爆炸
        boom: {
            more: 'effect/boom/boomMore',
            one: 'effect/boom/boomOne',
        },
        // 雪花
        snow: {
            down: {
                small: 'effect/snowFall/snowFall01',
                middle: 'effect/snowFall/snowFall02',
                big: 'effect/snowFall/snowFall03',
            },
            right: {
                small: 'effect/snowFall/snowFallLeft01',
                middle: 'effect/snowFall/snowFallLeft02',
                big: 'effect/snowFall/snowFallLeft03',
            },
            left: {
                small: 'effect/snowFall/snowFallRight01',
                middle: 'effect/snowFall/snowFallRight02',
                big: 'effect/snowFall/snowFallRight03',
            },
        },
    },

    horizontal: {
        // 流血
        bloodDown: {
            style1: 'effect/bloodDown/1bloodDown1280',
            style2: 'effect/bloodDown/2bloodDown1280',
            style3: 'effect/bloodDown/3bloodDown1280',
        },
        // 星火
        spotFire: {
            small: 'effect/spotFire/spotFireSmall1280',
            middle: 'effect/spotFire/spotFireMiddle1280',
            big: 'effect/spotFire/spotFireBig1280',
        },
    },
    vertical: {
        bloodDown: {
            style1: 'effect/bloodDown/1bloodDown720',
            style2: 'effect/bloodDown/2bloodDown720',
            style3: 'effect/bloodDown/3bloodDown720',
        },
        spotFire: {
            small: 'effect/spotFire/spotFireSmall720',
            middle: 'effect/spotFire/spotFireMiddle720',
            big: 'effect/spotFire/spotFireBig720',
        },
    },
};

class FontData {
    constructor () {
        this.size = 20;
        this.color = '#ffffff';
        this.family = FontType.Font0.font;
        this.bold = false;// 加粗
        this.italic = false;// 倾斜
        this.underline = false;// 下划线
        this.align = Type.TextAlign.Center;
        this.line = 1;// 行距
    }

    setData (font) {
        if (!font) {
            return;
        }

        this.size = parseInt(font.size.toString());
        this.color = font.color;
        this.family = font.family;
        this.bold = font.style.bold;
        this.italic = font.style.italic;
        this.underline = font.style.underline;
        this.align = font.align;
        this.line = parseFloat(font.line.toString());
    }
}

class BaseData {
    constructor (name, type) {
        this.id = genUUID();
        this.templateID = null; // 模板ID
        this.name = name || '';
        this.type = type || '';
        this.lockPos = false;
        this.lockSizeRatio = true;
        this.position = { x: 0, y: 0 };
        this.size = { width: 0, height: 0 };
        this.scale = { x: 1, y: 1 };
        this.active = true;
        this.opacity = 255;
        this.color = '#ffffff';
        this.zIndex = 1;
    }
}

// 运行时并不会使用该字段,为编辑器而设计的
const ImageAutoFitMode = {
    None: {
        name: '无',
        type: 'none',
    },
    FullScreen: {
        name: '铺满全屏',
        type: 'full-screen',
    },
    RatioWidth: {
        name: '图片比例(设置宽)',
        type: 'ratio-width',
    },
    RatioHeight: {
        name: '图片比例(设置高)',
        type: 'ratio-height',
    },
    TextureSize: {
        name: '图片大小',
        type: 'texture-size',
    },
};

class HelperInsertScene {
    constructor (zIndex) {
        this.id = genUUID();
        this.name = '快速插入场景';
        this.type = AvgType.HelperInsertScene.type;
        this.zIndex = zIndex || 0;
    }
}

class HelperInsertRole {
    constructor (zIndex) {
        this.id = genUUID();
        this.name = '快速插入人物';
        this.type = AvgType.HelperInsertRole.type;
        this.zIndex = zIndex || 0;
    }
}

class ImageBgData extends BaseData {
    constructor (name, texture) {
        super(name, AvgType.ImageBg.type);
        this.linkID = null; // 关联的配置sceneCfg.tag.id
        this.texture = texture || null; // sceneCfg.tag.image
        this.sizeMode = cc.Sprite.SizeMode.CUSTOM;
        this.autoFitMode = ImageAutoFitMode.None.type;
    }
}

class ImageDrawData extends BaseData {
    constructor (name, texture) {
        super(name, AvgType.ImageDraw.type);
        this.linkID = null; // 关联的配置roleCfg.tag.id
        this.texture = texture || null; // roleCfg.tag.image
        this.sizeMode = cc.Sprite.SizeMode.CUSTOM;
        this.autoFitMode = ImageAutoFitMode.None.type;
    }
}

class ImageHeadData extends BaseData {
    constructor (name, texture) {
        super(name, AvgType.ImageHead.type);
        this.linkID = null; // 关联的配置roleCfg.tag.id
        this.texture = texture || null; // roleCfg.tag.imageHead
        this.sizeMode = cc.Sprite.SizeMode.CUSTOM;
        this.autoFitMode = ImageAutoFitMode.None.type;
    }
}

class ImageItemData extends BaseData {
    constructor (name, texture) {
        super(name, AvgType.ImageItem.type);
        this.texture = texture || null;
        this.sizeMode = cc.Sprite.SizeMode.CUSTOM;
        this.autoFitMode = ImageAutoFitMode.None.type;
    }
}

class PlotMenuItemData {
    constructor (text) {
        this.id = genUUID();
        this.type = AvgType.PlotMenu.sub.menu;
        this.text = text || '新的选项';
        this.size = { width: PlotMenuItemData.width(), height: PlotMenuItemData.height() };
        this.position = { x: 0, y: 0 };
    }

    static width () {
        return 274;
    }

    static height () {
        return 54;
    }
}

class PlotMenuData extends BaseData {
    constructor (name, data) {
        super(name, AvgType.PlotMenu.type);
        this.textureNormal = DefaultValue.PlotMenuNormalTexture;
        this.texturePress = DefaultValue.PlotMenuPressTexture;
        this.itemFont = new FontData();
        this.itemFont.color = '#ffffff';

        this.limit = {
            id: genUUID(), // id 限时未完成的事件ID
            type: AvgType.PlotMenu.sub.limit,
            enabled: false, // 是否开启
            time: 10,
            font: new FontData(),
            bg: DefaultValue.PlotMenuLimitProgress1,
            size: { width: 73, height: 73 },
            position: { x: 0, y: 0 },
        };
        this.limit.font.color = '#333333';
        this.initItems(2);
    }

    initItems (len) {
        let width = PlotMenuItemData.width();
        let height = PlotMenuItemData.height();
        let space = 10;
        this.items = [];
        for (let i = 1; i <= len; i++) {
            let item = new PlotMenuItemData(`剧情选项${i}`);
            item.size.width = width;
            item.size.height = height;
            this.items.push(item);
        }
        // 竖向排列
        let center = parseInt(len / 2);
        if (len % 2 === 0) {
            // 偶数
            for (let i = 0; i < len; i++) {
                if (i < center) {
                    let y = -(center - i) * (height + space) + (height + space) / 2;
                    this.items[i].position.y = -y;
                } else if (i === center) {
                    this.items[i].position.y = -(height + space) / 2;
                } else if (i > center) {
                    let y = (i - center) * (height + space) + (height + space) / 2;
                    this.items[i].position.y = -y;

                }
            }
        } else {
            // 奇数
            for (let i = 0; i < len; i++) {
                if (i < center) {
                    let y = -(center - i) * (height + space);
                    this.items[i].position.y = -y;
                } else if (i > center) {
                    let y = (i - center) * (height + space);
                    this.items[i].position.y = -y;
                } else {
                    this.items[i].position.y = 0;
                }
            }
        }
        this.size.height = (len - 1) * space + len * height;
        this.size.width = width;
    }
}

// const DefaultValue = {
//     TalkHeadTexture: 'res/default/role-1.png',
//     TalkRoleNameTexture: 'res/default/frame-name.png',
//     TalkTextBgHorizontalTexture: 'res/default/frame-text.png',
//     TalkTextBgVerticalTexture: 'res/default/frame-text2.png',
//
//     PlotMenuNormalTexture: 'res/default/plot-menu.png',
//     PlotMenuPressTexture: 'res/default/plot-menu.png',
//
//     PieceAvgMenu: 'res/default/avg-menus.png',
//
//
//     UiBackBtnTexture: 'res/default/ui-file-mgr/back.png',
//     UiBgTexture: 'res/default/cover-bg.png',
//     UiButtonNormalTexture: 'res/default/btn-normal.png',
//     UiButtonPressTexture: 'res/default/btn-press.png',
//
//     UiFileMgrNormalTexture: 'res/default/ui-file-mgr/frame-normal.png',
//     UiFileMgrPressTexture: 'res/default/ui-file-mgr/frame-normal.png',
//     UiFileMgrIconTexture: 'res/default/ui-file-mgr/icon.png',
//
//     UiEnvBoardTexture: 'res/default/ui-env/frame.png',
//     UiEnvProgress1: 'res/default/ui-env/slider1.png',
//     UiEnvProgress2: 'res/default/ui-env/slider2.png',
//     UiEnvProgressBtn: 'res/default/ui-env/button.png',
//
//     UiMenuNormalTexture: 'res/default/btn-normal.png',
//     UiMenuPressTexture: 'res/default/btn-press.png',
//
// };

const DefaultValue = {
    TalkHeadTexture: '7e6be316-51b4-4017-a18d-48bc46ec939a',
    TalkRoleNameTexture: 'a3aa2af6-90f7-4980-bea9-84e84dfa3ec6',
    TalkTextBgHorizontalTexture: '784474e3-9fd6-4090-9012-617a1a693003',
    TalkTextBgVerticalTexture: 'd56760d2-ab70-4cb2-8791-592bf8a05ad9',

    PlotMenuNormalTexture: 'd82003cf-0196-4fe8-aadc-c1ac67a3cc1f',
    PlotMenuPressTexture: 'd82003cf-0196-4fe8-aadc-c1ac67a3cc1f',
    PlotMenuLimitProgress1: 'dfaf3a76-06e1-4ebe-823d-a006c3ce0a8d',
    PlotMenuLimitProgress2: '6b58bb48-405d-42bc-b8ff-5a95d61bb698',

    ElementVideoPlayFlag: '71705896-527a-42bb-8e6b-6883ce2cc53a',
    PieceAvgMenu: '5bd433c6-ab0c-443f-9374-e19d68c08f00',

    UiBackBtnTexture: '80683f67-fb22-4b5f-a157-e86f58fe3518',
    UiBgTexture: 'fcd183b7-5e0c-4203-8f15-2c619df86c54',
    UiButtonNormalTexture: '4a097b6d-50fd-4631-b472-da036cd8f163',
    UiButtonPressTexture: '89550671-cc19-4117-854c-ec319787110c',

    UiFileMgrNormalTexture: '3dbaa718-5e90-477d-ba66-e98b509c8887',
    UiFileMgrPressTexture: '3dbaa718-5e90-477d-ba66-e98b509c8887',
    UiFileMgrIconTexture: 'd9a576f1-8f3b-484f-8758-989abc3132a0',

    UiEnvBoardTexture: '471d56a8-c474-41cd-af5a-030ee3944b7b',
    UiEnvProgress1: '6712c1aa-05e3-453a-9473-c62350aab775',
    UiEnvProgress2: '6da73290-5995-44b3-8507-3ce2796869ee',
    UiEnvProgressBtn: '9d68a76f-d6e5-495c-9d7e-066c0b143409',

    UiMenuNormalTexture: '4a097b6d-50fd-4631-b472-da036cd8f163',
    UiMenuPressTexture: '89550671-cc19-4117-854c-ec319787110c',

    TemplateAudio: '8675a572-9a8d-4acd-a034-e86f23629347',
    TemplateImageBgHorizontal: 'e97c92b0-d78a-468c-b09b-fbc21f68a1e0',
    TemplateImageBgVertical: 'e97c92b0-d78a-468c-5pk0-fbc21f68a1e0',
    TemplateImageDraw: 'a2e13d4c-319d-4af4-8996-58689f5e5d7f',
    TemplateImageItem: '4dfb5e28-608e-4d12-ab90-700f4dcc7e6d',
    TemplateVideoHorizontal: 'beee34e7-62e5-4b53-bd61-4c2da7f138e3',

    PwdLockImageLock1: '651d667e-17a3-4db5-bf37-0e61a05afbcc',
    PwdLockImageOpen1: 'aad0671e-2afb-4524-8f55-48f267e456a1',
    PwdLockImageLock2: '39912cde-b092-49c1-820e-c3fd96f9b14b',
    PwdLockImageOpen2: 'ef2b766-e9e1-47ee-8db5-b90282cac285',
};

class TalkData extends BaseData {
    constructor (name) {
        super(name, AvgType.Talk.type);
        this.head = {
            id: genUUID(),
            type: AvgType.Talk.sub.head,
            active: true,
            texture: DefaultValue.TalkHeadTexture,
            linkID: null, // 对应人物配置里面的形象ID
            position: { x: 0, y: 0 },
            size: { width: 0, height: 0 },
            scale: { x: 1, y: 1 },
        };
        this.roleName = {
            id: genUUID(),
            type: AvgType.Talk.sub.name,
            active: true,
            position: { x: 0, y: 0 },
            size: { width: 0, height: 0 }, // 暂时没有用到
            text: {
                font: new FontData(),
                string: '名字',
            },
            bg: {
                texture: DefaultValue.TalkRoleNameTexture,
                size: { width: 0, height: 0 },
                active: true,
            },
        };

        this.talk = {
            id: genUUID(),
            type: AvgType.Talk.sub.panel,
            position: { x: 0, y: 0 },
            size: { width: 0, height: 0 }, // 和bg.size保持一致
            bg: {
                active: true,
                size: { width: 0, height: 0 },
                texture: null,
            },
            text: {
                id: genUUID(),
                type: AvgType.Talk.sub.text,
                position: { x: 0, y: 0 },
                size: { width: 0, height: 0 },
                string: '对话内容',
                font: new FontData(),
            },
        };
        this.talk.text.font.color = '#ffffff';
    }

    // fixme 因为子元素的适配,位置信息是否需要新的计算方式
    resetWithHorizontal (isShowHead = true) {
        this.position.y = -277.5;// 默认位置在屏幕底部
        this.size.width = this.talk.bg.size.width = this.talk.size.width = 1280;
        this.size.height = this.talk.bg.size.height = this.talk.size.height = 165;

        this.head.texture = DefaultValue.TalkHeadTexture;
        this.head.position.x = -539;
        this.head.position.y = -2;
        this.head.size.width = 147;
        this.head.size.height = 141;

        this.roleName.bg.texture = DefaultValue.TalkRoleNameTexture;
        this.roleName.bg.size.width = 206;
        this.roleName.bg.size.height = 57;
        this.roleName.position.x = 110;
        this.roleName.position.y = 117;

        if (isShowHead) {
            this.talk.text.position.x = -450;
            this.talk.text.position.y = 52;
            this.talk.text.size.width = 1050;
        } else {
            this.talk.text.position.x = -609;
            this.talk.text.position.y = 52;
            this.talk.text.size.width = 1210;
        }

        this.talk.bg.texture = DefaultValue.TalkTextBgHorizontalTexture;
    }

    resetWithVertical (isShowHead = true) {
        this.position.y = -558;// 默认位置在屏幕底部
        this.size.width = this.talk.bg.size.width = this.talk.size.width = 720;
        this.size.height = this.talk.bg.size.height = this.talk.size.height = 165;

        this.head.texture = DefaultValue.TalkHeadTexture;
        this.head.position.x = -274;
        this.head.position.y = 12;
        this.head.size.width = 147;
        this.head.size.height = 141;

        this.roleName.bg.texture = DefaultValue.TalkRoleNameTexture;
        this.roleName.bg.size.width = 160;
        this.roleName.bg.size.height = 64;
        this.roleName.position.x = 110;
        this.roleName.position.y = 117;

        if (isShowHead) {
            this.talk.text.position.x = -181;
            this.talk.text.position.y = 40;
            this.talk.text.size.width = 507;
        } else {
            this.talk.text.position.x = -345;
            this.talk.text.position.y = 40;
            this.talk.text.size.width = 680;
        }

        this.talk.bg.texture = DefaultValue.TalkTextBgVerticalTexture;

    }

    setInfo (headID, headTexture, roleName, talkString, font) {
        this.head.texture = headTexture;
        headID && (this.head.linkID = headID);
        roleName && (this.roleName.text.string = roleName);
        talkString && (this.talk.text.string = talkString);

        if (font) {
            // this.roleName.text.font.setData(font);
            this.talk.text.font.setData(font);
        }
    }
}

class TextData extends BaseData {
    constructor (name) {
        super(name, AvgType.Text.type);
        this.direction = Type.Text.DirectionHorizontal;
        this.string = '请输入文本';
        this.textFont = new FontData();
        this.textFont.color = '#333333';
    }
}


class PasswordLockData extends BaseData {
    constructor (name) {
        super(name, AvgType.PasswordLock.type);
        this.isLock = true; // 锁定状态
        this.imageLock = null;
        this.imageOpen = null;
        this.class = PasswordLockClassType.Electronic.type; // 锁的类型种类
        this.style = PasswordLockStyleType.Type1.type; // 锁的颜色款式
        this.password = '01234567';
        this.openTips = '密码箱已经打开';
        this.tipsFont = new FontData();

        this.result = {
            succeed: {
                id: genUUID(),
                name: '开锁成功',
            },
            failed: {
                id: genUUID(),
                name: '开锁失败',
            },
        };
        this.updateImage();
    }

    updateImage () {
        if (this.style === PasswordLockStyleType.Type1.type) {
            this.imageLock = DefaultValue.PwdLockImageLock1;
            this.imageOpen = DefaultValue.PwdLockImageOpen1;
        } else if (this.style === PasswordLockStyleType.Type2.type) {
            this.imageLock = DefaultValue.PwdLockImageLock2;
            this.imageOpen = DefaultValue.PwdLockImageOpen2;
        }
    }
}

class UiCoverData extends BaseData {
    constructor () {
        super('封面', AvgType.UiCover.type);
        this.lockPos = true;
        this.style = Type.UiCoverStyle.Default;
        this.bg = {
            name: '背景',
            texture: DefaultValue.UiBgTexture,
            position: { x: 0, y: 0 },
            size: { width: 0, height: 0 },
        };

        this.buttons = {
            normalTexture: DefaultValue.UiButtonNormalTexture,
            pressTexture: DefaultValue.UiButtonPressTexture,
            position: { x: 0, y: 0 },
            font: new FontData(),
            items: [
                {
                    text: '开始',
                    position: { x: 0, y: 0 },
                    size: { width: 155, height: 44 },
                    type: Type.UiButton.CoverBegan,
                },
                {
                    text: '继续',
                    position: { x: 0, y: 0 },
                    size: { width: 155, height: 44 },
                    type: Type.UiButton.CoverContinue,
                },
                {
                    text: '设置',
                    position: { x: 0, y: 0 },
                    size: { width: 155, height: 44 },
                    type: Type.UiButton.CoverSet,
                },
            ],
        };

        this.buttons.font.color = '#333333';
    }

    resetWithHorizontalMode (size) {
        this.size.width = size.width;
        this.size.height = size.height;

        this.style = Type.UiCoverStyle.Custom;
        this.bg.size.width = size.width;
        this.bg.size.height = size.height;

        this.buttons.position.x = -410;
        this.buttons.position.y = -158;
    }

    resetWithVerticalMode (size) {
        this.size.width = size.width;
        this.size.height = size.height;

        this.style = Type.UiCoverStyle.Custom;
        this.bg.size.width = size.width;
        this.bg.size.height = size.height;

        this.buttons.position.x = -203;
        this.buttons.position.y = -484;
    }
}

class UiMenuData extends BaseData {
    constructor () {
        super('菜单', AvgType.UiMenu.type);
        this.lockPos = true;
        this.backBtnTexture = DefaultValue.UiBackBtnTexture;

        this.style = Type.UiCoverStyle.Default;
        this.bg = {
            name: '背景',
            texture: DefaultValue.UiBgTexture,
            position: { x: 0, y: 0 },
            size: { width: 0, height: 0 },
        };

        this.buttons = {
            normalTexture: DefaultValue.UiMenuNormalTexture,
            pressTexture: DefaultValue.UiMenuPressTexture,
            position: { x: 0, y: 0 },

            font: new FontData(),
            items: [
                {
                    text: '保存',
                    position: { x: 0, y: 0 },
                    size: { width: 155, height: 44 },
                    type: Type.UiButton.MenuSave,
                },
                {
                    text: '读取',
                    position: { x: 0, y: 0 },
                    size: { width: 155, height: 44 },
                    type: Type.UiButton.MenuRead,
                },
                {
                    text: '设置',
                    position: { x: 0, y: 0 },
                    size: { width: 155, height: 44 },
                    type: Type.UiButton.MenuSet,
                },
                {
                    text: '退出游戏',
                    position: { x: 0, y: 0 },
                    size: { width: 155, height: 44 },
                    type: Type.UiButton.MenuExit,
                },
            ],
        };
        this.buttons.font.color = '#333333';
    }

    resetWithHorizontalMode (size) {
        this.size.width = size.width;
        this.size.height = size.height;

        this.style = Type.UiCoverStyle.Custom;
        this.bg.size.width = size.width;
        this.bg.size.height = size.height;

        this.buttons.position.x = -410;
        this.buttons.position.y = -114;
    }

    resetWithVerticalMode (size) {
        this.size.width = size.width;
        this.size.height = size.height;

        this.style = Type.UiCoverStyle.Custom;
        this.bg.size.width = size.width;
        this.bg.size.height = size.height;

        this.buttons.position.x = -212;
        this.buttons.position.y = -444;
    }
}

class UiEnvData extends BaseData {
    constructor () {
        super('环境设置', AvgType.UiEnv.type);
        this.lockPos = true;
        this.style = Type.UiCoverStyle.Default;

        this.backBtnTexture = DefaultValue.UiBackBtnTexture;

        this.bg = {
            name: '背景',
            texture: DefaultValue.UiBgTexture,
            position: { x: 0, y: 0 },
            size: { width: 0, height: 0 },
        };

        this.sets = {
            boardTexture: DefaultValue.UiEnvBoardTexture,
            boardSize: { width: 644, height: 241 },
            progress1: DefaultValue.UiEnvProgress1,
            progress2: DefaultValue.UiEnvProgress2,
            progressButton: DefaultValue.UiEnvProgressBtn,
            position: { x: 0, y: 0 },
            items: [
                {
                    text: '音量',
                    type: Type.UiButton.EnvSetVolume,
                    position: { x: 0, y: 0 },
                },
                {
                    text: '语速',
                    type: Type.UiButton.EnvSetTalkSpeed,
                    position: { x: 0, y: 0 },
                },
            ],
        };
    }

    resetWithHorizontalMode (size) {
        this.size.width = size.width;
        this.size.height = size.height;

        this.style = Type.UiCoverStyle.Custom;
        this.bg.size.width = size.width;
        this.bg.size.height = size.height;

        this.sets.position.x = 0;
        this.sets.position.y = 0;
    }

    resetWithVerticalMode (size) {
        this.size.width = size.width;
        this.size.height = size.height;

        this.style = Type.UiCoverStyle.Custom;
        this.bg.size.width = size.width;
        this.bg.size.height = size.height;

        this.sets.position.x = 0;
        this.sets.position.y = 0;
    }
}

class UiFileMgrData extends BaseData {
    constructor () {
        super('档案管理', AvgType.UiFileMgr.type);
        this.lockPos = true;
        this.style = Type.UiFileMgrStyle.Default;
        this.bg = {
            name: '背景',
            texture: DefaultValue.UiBgTexture,
            position: { x: 0, y: 0 },
            size: { width: 0, height: 0 },
        };
        this.backBtnTexture = DefaultValue.UiBackBtnTexture;
        this.lists = {
            normalTexture: DefaultValue.UiFileMgrNormalTexture,
            pressTexture: DefaultValue.UiFileMgrPressTexture,
            iconTexture: DefaultValue.UiFileMgrIconTexture,
            iconSize: { width: 186, height: 105 },
            position: { x: 0, y: 0 },
            font: new FontData(),
            items: [
                {
                    name: '存档1',
                    time: '2019/01/01',
                    size: { width: 210, height: 172 },
                    type: Type.UiButton.FileMgrItem,
                },
                {
                    name: '存档2',
                    time: '2019/01/01',
                    size: { width: 210, height: 172 },
                    type: Type.UiButton.FileMgrItem,
                },
                {
                    name: '存档3',
                    time: '2019/01/01',
                    size: { width: 210, height: 172 },
                    type: Type.UiButton.FileMgrItem,
                },
                {
                    name: '存档4',
                    time: '2019/01/01',
                    size: { width: 210, height: 172 },
                    type: Type.UiButton.FileMgrItem,
                },
                {
                    name: '存档5',
                    time: '2019/01/01',
                    size: { width: 210, height: 172 },
                    type: Type.UiButton.FileMgrItem,
                },
                {
                    name: '存档6',
                    time: '2019/01/01',
                    size: { width: 210, height: 172 },
                    type: Type.UiButton.FileMgrItem,
                },
            ],
        };
        this.lists.font.color = '#333333';
        this.lists.font.size = 16;
    }

    resetWithHorizontalMode (size) {
        this.size.width = size.width;
        this.size.height = size.height;

        this.style = Type.UiCoverStyle.Custom;
        this.bg.size.width = size.width;
        this.bg.size.height = size.height;

        this.lists.position.x = 0;
        this.lists.position.y = 0;
    }

    resetWithVerticalMode (size) {
        this.size.width = size.width;
        this.size.height = size.height;

        this.style = Type.UiCoverStyle.Custom;
        this.bg.size.width = size.width;
        this.bg.size.height = size.height;

        this.lists.position.x = 0;
        this.lists.position.y = 0;
    }
}

class PlotJumpData {
    constructor () {
        this.id = genUUID();
        this.name = '剧情跳转';
        this.type = AvgType.PlotJump.type;
        this.jumpPlotID = null;
    }
}

class AudioBgStopGlobalData {
    constructor () {
        this.id = genUUID();
        this.name = '停止全局背景音乐';
        this.type = AvgType.AudioBgStopGlobal.type;
    }
}

class AudioBgData {
    constructor (name) {
        this.id = genUUID();
        this.name = name || '背景音乐';
        this.type = AvgType.AudioBg.type;
        this.src = null;
        this.globalPlay = false; // 全局播放属性
    }
}

class AudioEffectData {
    constructor (name) {
        this.id = genUUID();
        this.name = name || '背景音效';
        this.type = AvgType.AudioEffect.type;
        this.src = null;
    }
}

class AudioAsideData {
    constructor (name) {
        this.id = genUUID();
        this.name = name || '配音';
        this.type = AvgType.AudioAside.type;
        this.src = null;
    }
}

class EffectRainData extends BaseData {
    constructor (name) {
        super(name, AvgType.EffectRain.type);
        this.state = Type.EffectRainType.small.type;
        this.size.width = 100;
        this.direction = Type.EffectDirection.Down.type;
        this.size.height = 100;
        this.prefab = 'prefab/rain';
    }
}

class EffectSnowData extends BaseData {
    constructor (name) {
        super(name, AvgType.EffectSnow.type);
        this.state = Type.EffectSnowType.small.type;
        this.direction = Type.EffectDirection.Down.type;
        this.size.width = 100;
        this.size.height = 100;
    }
}

// todo 删除了
class EffectWinData extends BaseData {
    constructor (name) {
        super(name, AvgType.EffectWin.type);
        this.state = Type.EffectWinType.small.type;
        this.size.width = 100;
        this.size.height = 100;
    }
}

class EffectLeafFallData extends BaseData {
    constructor (name) {
        super(name, AvgType.EffectLeafFall.type);
        this.state = Type.EffectLeafFallType.small.type;
        this.size.width = 100;
        this.size.height = 100;
    }
}

class EffectFogData extends BaseData {
    constructor (name) {
        super(name, AvgType.EffectFog.type);
        this.state = Type.EffectFogType.small.type;
        this.size.width = 100;
        this.size.height = 100;
    }
}

class EffectLightData extends BaseData {
    constructor (name) {
        super(name, AvgType.EffectLight.type);
        this.state = Type.EffectLightType.middle.type;
        this.size.width = 100;
        this.size.height = 100;
    }
}

class EffectFireData extends BaseData {
    constructor (name) {
        super(name, AvgType.EffectFire.type);
        this.state = Type.EffectFireType.less.type;
        this.size.width = 100;
        this.size.height = 100;
    }
}

class EffectSpotFireData extends BaseData {
    constructor (name) {
        super(name, AvgType.EffectSpotFire.type);
        this.state = Type.EffectSpotFireType.less.type;
        this.size.width = 100;
        this.size.height = 100;
    }
}

class EffectBoomData extends BaseData {
    constructor (name) {
        super(name, AvgType.EffectBoom.type);
        this.state = Type.EffectBoomType.one.type;
        this.size.width = 100;
        this.size.height = 100;
    }
}

class EffectBloodDownData extends BaseData {
    constructor (name) {
        super(name, AvgType.EffectBloodDown.type);
        this.state = Type.EffectBloodDownType.less.type;
        this.size.width = 100;
        this.size.height = 100;
    }
}

class EffectBloodDripData extends BaseData {
    constructor (name) {
        super(name, AvgType.EffectBloodDrip.type);
        this.state = Type.EffectBloodDripType.less.type;
        this.size.width = 100;
        this.size.height = 100;
    }
}

class VideoPlotData extends BaseData {
    constructor (name, uuid) {
        super(name, AvgType.VideoPlot.type);
        this.lockSizeRatio = false;
        this.src = uuid === undefined ? '' : uuid;
        this.size.height = this.size.width = 100;
        this.isRemote = false;
        this.time = 0; // 视频的时长
        this.resolutionRatio = {
            // 视频自身的分辨率
            width: 0,
            height: 0,
        };
        // 适应播放器：视频保持自己的长宽比。只是根据播放器的大小，调整缩放比例
        // 铺满播放器：视频显示的长款完全决定于播放器
        this.displayMode = Type.VideoDisplayMode.Fit.type; // 视频在播放器显示的模式
    }

    resetWithVertical () {
        this.size.width = 720;
        this.size.height = 1280;
    }

    resetWithHorizontal () {
        this.size.width = 1280;
        this.size.height = 720;
    }
}

class ActionNone {
    constructor () {
        this.type = ActionType.None.type;
        this.delay = 0;
        this.time = 0;
    }
}

class ActionMove {
    constructor () {
        this.type = ActionType.Move.type;
        this.time = 1;
        this.delay = 0;
        this.x1 = this.x2 = this.y1 = this.y2 = 0;
    }
}

class ActionFadeIn {
    constructor () {
        this.type = ActionType.FadeIn.type;
        this.delay = 0;
        this.time = 1;
    }
}

class ActionFadeOut {
    constructor () {
        this.type = ActionType.FadeOut.type;
        this.delay = 0;
        this.time = 1;
    }
}

class ActionShake {
    constructor () {
        this.type = ActionType.Shake.type;
        this.delay = 0;
        this.time = 1;
        this.strength = ShakeStrength.normal.type; // 震动强度
    }
}

class ActionScale {
    constructor () {
        this.type = ActionType.Scale.type;
        this.delay = 0;
        this.time = 1;
        this.scaleFrom = 1;
        this.scaleTo = 2;
    }
}

class ActionRotation {
    constructor () {
        this.type = ActionType.Rotation.type;
        this.delay = 0;
        this.time = 1;
        this.clockwise = true;
        this.rotationPoint = { x: 0, y: 0 }; // 注意:该参数会影响节点的位置,(0,0)为中点
        this.angle = 0;
    }
}

class ActionBlur {
    constructor () {
        this.type = ActionType.Blur.type;
        this.delay = 0;
        this.time = 1;
        this.start = 0; // 起始模糊比例
        this.end = 100; // 结束模糊比例
    }
}

class ActionAudioPlay {
    constructor () {
        this.type = ActionAudioType.Play.type;
        this.delay = 0;
        this.volume = 100;
        this.time = 0;
        this.loop = false;

        this.fadeIn = false;
        this.fadeOut = false;
        this.fadeInTime = 2;
        this.fadeOutTime = 2;
    }
}

class ActionVideoPlay {
    constructor () {
        this.type = ActionVideoType.Play.type;
        this.delay = 0;
        this.volume = 100;
        this.time = 0;
        this.loop = false; // 参数废弃
        this.isFullPlay = true;
    }
}

const EventEmitType = {
    None: {
        name: '无',
        type: 'none',
    },
    Click: {
        name: '单击',
        type: 'click',
    },
    Clicks: {
        name: '连击',
        type: 'clicks',
    },
    Press: {
        name: '长按',
        type: 'press',
    },
    SlideLeft: {
        name: '左滑',
        type: 'slide-left',
    },
    SlideRight: {
        name: '右滑',
        type: 'slide-right',
    },
    SlideUp: {
        name: '上滑',
        type: 'slide-up',
    },
    SlideDown: {
        name: '下滑',
        type: 'slide-down',
    },
};

class EventData {
    constructor (type) {
        this.id = genUUID();
        this.element = null;
        this.type = type;
        this.count = 1;
        this.emitType = EventEmitType.Click.type;
    }

    // setPlotType (jump, delayTime) {
    //     this.data = new EventPlotData();
    //     if (jump) {
    //         this.data.jump = jump;
    //     }
    //     if (delayTime) {
    //         this.data.delayTime = delayTime;
    //     }
    // }
}

class EventValueData extends EventData {
    constructor () {
        super(EventType.Value.type);
        this.valueID = ''; // 数值的UUID
        this.exec = []; // 执行内容
        this.text = ''; // 显示的文本
        this.font = new FontData();
    }
}

class EventPlotData extends EventData {
    constructor () {
        super(EventType.Plot.type);
        this.jump = null;
        this.delayTime = 0;
        this.action = ActionType.None.type;
    }
}

const EventType = {
    Plot: {
        name: '剧情事件',
        type: 'plot',
    },
    Value: {
        name: '数值事件',
        type: 'value',
    },
};

const ValueJudgeSituationEmitType = {
    None: {
        type: 'none',
        name: '无',
    },
    EmitEvent: {
        type: 'emit-event',
        name: '触发事件',
    },
};
const PasswordLockClassType = {
    Electronic: {
        type: 'electronic',
        name: '电子密码锁',
    },
};
const PasswordLockStyleType = {
    Type1: {
        type: 'type1',
        name: '棕色',
    },
    Type2: {
        type: 'type2',
        name: '银白',
    },
};

class ValueJudgeData {
    constructor (name) {
        this.id = genUUID();
        this.name = name || '数值判断器';
        this.type = AvgType.ValueJudge.type;
        this.valueID = ''; // 要操作的数值
        this.exec = []; // 比较的公式

        this.situation = {
            greater: {
                id: genUUID(),
                text: '大于', // 具体显示的文字
                emitType: ValueJudgeSituationEmitType.None.type,
            },
            less: {
                id: genUUID(),
                text: '小于', // 具体显示的文字
                emitType: ValueJudgeSituationEmitType.None.type,
            },
            equal: {
                id: genUUID(),
                text: '等于', // 具体显示的文字
                emitType: ValueJudgeSituationEmitType.None.type,
            },
        };
    }
}

const QTEEmitType = {
    None: {
        name: '无',
        type: 'none',
    },
    Click: {
        name: '点击',
        type: 'click',
    },
    Press: {
        name: '长按',
        type: 'press',
    },
    SlideLeft: {
        name: '左滑',
        type: 'slide-left',
    },
    SlideRight: {
        name: '右滑',
        type: 'slide-right',
    },
    SlideUp: {
        name: '上滑',
        type: 'slide-up',
    },
    SlideDown: {
        name: '下滑',
        type: 'slide-down',
    },
    SlideUpDown: {
        name: '上下滑动',
        type: 'slide-up-down',
    },
    SlideLeftRight: {
        name: '左右滑动',
        type: 'slide-left-right',
    },
};
const QTEStyleType = {
    Style1: {
        name: '样式1',
        type: 'style1',
    },
};

const QTETimerColorStyle = {
    Style1: {
        name: '经典1', // 备用字段
        colorTop: '#578AFF',
        colorBottom: '#1A2C53',
    },
    Style2: {
        name: '经典2',
        colorTop: '#e6bb76',
        colorBottom: '#5e3c03',
    },
    Style3: {
        name: '经典3',
        colorTop: '#e868f6',
        colorBottom: '#6d2576',
    },
};

class QTEData extends BaseData {
    constructor (name) {
        super(name, AvgType.QTE.type);
        this.mask = {
            active: true,
            color: '#000000',
            opacity: 150,
        };
        this.qte = {
            id: genUUID(),
            type: AvgType.QTE.sub.graphics,
            position: { x: 0, y: 0 },
            size: { width: 0, height: 0 },
            emitType: QTEEmitType.Click.type, // 类型
            clickCount: 1, // 点击次数
            style: {
                color: '#ffffff', // 暂时废弃的字段
                type: QTEStyleType.Style1.type,
            },
            // 图标
            icon: {
                color: '#ffffff',
                opacity: 255,
            },
            // 计时
            timer: {
                enabled: true, // 是否启用计时
                time: 1, // 计时时间, 单位s
                colorTop: '#ffffff', // 计时圈顶色
                colorBottom: '#777777', // 计时圈底色
                opacity: 255, // 计时圈透明度
            },
        };

        this.tips = {
            id: genUUID(),
            type: AvgType.QTE.sub.tips,
            text: '提示文本',
            font: new FontData(),
            opacity: 255,
            position: { x: 0, y: -160 },
        };

        this.unFinished = {
            reStart: false, // 重新从这个QTE开始
            rePlay: false, // 重新播放本页
        };
        this.result = {
            succeed: {
                id: genUUID(),
                name: '动作已完成',
            },
            failed: {
                id: genUUID(),
                name: '动作未完成',
            },
        };
        this._initDefault();
    }

    _initDefault () {
        this.qte.size.width = 235;
        this.qte.size.height = 235;
    }
}

const Action = {
    None: ActionNone,
    Move: ActionMove,
    FadeIn: ActionFadeIn,
    FadeOut: ActionFadeOut,
    Scale: ActionScale,
    Shake: ActionShake,
    Rotation: ActionRotation,
    Blur: ActionBlur,
    AudioPlay: ActionAudioPlay,
    VideoPlay: ActionVideoPlay,
};

const Type = {
    Pieces: {
        Content: 'piece-content', // 内容
        Template: 'piece-template', // 模板
        UiDefault: 'ui-default', // 默认UI
        UiCustom: 'ui-custom', // 自定义ui
    },
    // 基本UI分类
    UiDefault: {
        Cover: 'cover',
        Env: 'env',
        Menu: 'menu',
        FileMgr: 'file-mgr',
    },
    UiCoverStyle: {
        Default: 'default',
        Custom: 'custom',
    },
    UiFileMgrStyle: {
        Default: 'default',
    },
    Plot: {
        Chapter: 'plot_chapter', // 章节,存在的意义不大,仅仅是剧情的合集
        Content: 'plot_content', // 具体剧情
    },
    PlotMenu: {
        JumpPlot: {
            // 跳转剧情类型的菜单
            name: '剧情事件',
            type: 'jump_plot',
        },
        ValueCalc: {
            name: '数值事件',
            type: 'value_calc',
        },
    },
    Text: {
        DirectionHorizontal: 'horizontal',
        DirectionVertical: 'vertical',
    },
    TextAlign: {
        Left: 'left',
        Right: 'right',
        Center: 'center',
    },
    Shake: ShakeStrength,
    StartingMoment: startingMoment,
    FontType: FontType,
    TimelineType: TimelineType,
    UiButton: {
        MenuSave: 'Menu_Save',
        MenuRead: 'Menu_Read',
        MenuSet: 'Menu_Set',
        MenuExit: 'Menu_Exit',

        CoverBegan: 'Cover_Began',
        CoverContinue: 'Cover_Continue',
        CoverSet: 'Cover_Set',

        FileMgrItem: 'FileMgr_Item',

        EnvSetVolume: 'Env_SetVolume',
        EnvSetTalkSpeed: 'Env_TalkSpeed',
    },
    ActionAudioType: ActionAudioType,
    ActionVideoType: ActionVideoType,
    EffectDirection: {
        Down: {
            name: '向下',
            type: 'down',
        },
        Left: {
            name: '向左',
            type: 'left',
        },
        Right: {
            name: '向右',
            type: 'right',
        },
    },
    EffectWinType: {
        small: {
            name: '微风席面',
            type: 'small',
        },
        middle: {
            name: '秋风瑟瑟',
            type: 'middle',
        },
        big: {
            name: '飞沙走石',
            type: 'big',
        },
    },
    EffectLeafFallType: {
        small: {
            name: '稀疏几片',
            type: 'small',
        },
        middle: {
            name: '飘飘洒洒',
            type: 'middle',
        },
        big: {
            name: '漫天红叶',
            type: 'big',
        },
    },
    EffectFogType: {
        small: {
            name: '慢速',
            type: 'small',
        },
        middle: {
            name: '中速',
            type: 'middle',
        },
        big: {
            name: '快速',
            type: 'big',
        },
    },
    EffectLightType: {
        small: {
            name: '微光',
            type: 'small',
        },
        middle: {
            name: '柔和',
            type: 'middle',
        },
        big: {
            name: '炫目',
            type: 'big',
        },
    },
    EffectFireType: {
        less: {
            name: '烛火',
            type: 'less',
        },
        middle: {
            name: '火把',
            type: 'mid',
        },
        more: {
            name: '烈焰',
            type: 'more',
        },
    },
    EffectSpotFireType: {
        less: {
            name: '零星几点',
            type: 'less',
        },
        middle: {
            name: '劈啪作响',
            type: 'mid',
        },
        more: {
            name: '星桥火树',
            type: 'more',
        },
    },
    EffectBoomType: {
        one: {
            name: '单点引爆',
            type: 'one',
        },
        more: {
            name: '连环爆炸',
            type: 'more',
        },
    },
    EffectBloodDownType: {
        less: {
            name: '少量',
            type: 'less',
        },
        middle: {
            name: '中量',
            type: 'middle',
        },
        more: {
            name: '全屏',
            type: 'more',
        },
    },
    EffectBloodDripType: {
        less: {
            name: '少量',
            type: 'less',
        },
        middle: {
            name: '中量',
            type: 'middle',
        },
        more: {
            name: '全屏',
            type: 'more',
        },
    },
    EffectRainType: {
        small: {
            name: '细雨',
            type: 'small',
        },
        middle: {
            name: '中雨',
            type: 'middle',
        },
        big: {
            name: '暴雨',
            type: 'big',
        },
    },
    EffectSnowType: {
        small: {
            name: '小雪',
            type: 'small',
        },
        middle: {
            name: '中雪',
            type: 'middle',
        },
        big: {
            name: '暴雪',
            type: 'big',
        },
    },
    VideoDisplayMode: {
        Fit: {
            name: '适应播放器',
            type: 'fit',
        },
        Full: {
            name: '铺满播放器',
            type: 'full',
        },
    },
    PieceSwitchAnimationDirection: {
        Up: {
            name: '向上',
            type: 'up',
        },
        Down: {
            name: '向下',
            type: 'down',
        },
        Left: {
            name: '向左',
            type: 'left',
        },
        Right: {
            name: '向右',
            type: 'right',
        },
    },
    PieceSwitchAnimationEffect: {
        None: {
            type: 'none',
            name: '无',
        },
        FadeOut: {
            type: 'fadeOut',
            name: '淡出',
        },
        Erasure: {
            type: 'erasure',
            name: '擦除',
        },
        Rotate: {
            type: 'rotate',
            name: '旋转',
        },
        PullOut: {
            type: 'pullOut',
            name: '抽出',
        },
        PushOut: {
            type: 'pushOut',
            name: '推出',
        },
        Insert: {
            type: 'insert',
            name: '插入',
        },
    },
    PieceAniSkip: {
        Forbid: {
            name: '不可跳过',
            type: 'forbid',
        },
        Always: {
            name: '可直接跳过',
            type: 'always',
        },
        Once: {
            name: '播放一次可跳过',
            type: 'once',
        },
    },
    Value: {
        // 数值的类型
        Type: {
            Number: {
                type: 'number',
                name: '数字',
            },
            Bool: {
                type: 'bool',
                name: '布尔',
            },
            String: {
                type: 'string',
                name: '字符串',
            },
        },
        // 在游戏里面的类型
        GameType: {
            Normal: {
                type: 'common',
                name: '普通',
            },
            Global: {
                type: 'global',
                name: '全局',
            },
            System: {
                type: 'system',
                name: '系统',
            },

        },
    },
    // 数值计算器
    ValueCalculatorType: {
        Number: 'number', // 数字
        Variable: 'variable', // 变量
        Symbol: 'symbol', // 符号
    },
    PasswordLockStyleType: PasswordLockStyleType,
    PasswordLockClassType: PasswordLockClassType,
    Events: {
        EventType: EventType,
        EventEmitType: EventEmitType,
    },
    ValueJudgeSituationEmitType: ValueJudgeSituationEmitType,
    QTEEmitType: QTEEmitType,
    QTEStyleType: QTEStyleType,
    ImageAutoFitMode: ImageAutoFitMode,
};

const ProjectCfg = {
    init: 'cfg/init.json',
    assets: 'cfg/assets.json',
    ui: 'cfg/ui.json',
    plot: 'cfg/plot.json',
    piece: 'cfg/piece.json',
    roleScene: 'cfg/role-scene.json', // 快速入口人物场景配置文件
    numerical: 'cfg/numerical.json',
    videoFile: 'video/video.mp4',
    videoCfg: 'video/video.json',

    PieceFiles: {
        Animations: 'animations.json',
        Events: 'events.json',
        Elements: 'elements.json',
        TimeLine: 'timeline.json',
    },
};

const AvgData = {
    Type: Type,
    AvgType: AvgType,
    TimelineType: TimelineType,
    FontType: FontType,
    ActionType: ActionType,
    ActionAudioType: ActionAudioType,
    ActionVideoType: ActionVideoType,
    ShakeStrength: ShakeStrength,
    startingMoment: startingMoment,
    DefaultValue: DefaultValue,
    // element
    FontData: FontData,
    HelperInsertRole: HelperInsertRole,
    HelperInsertScene: HelperInsertScene,
    ImageBgData: ImageBgData,
    ImageDrawData: ImageDrawData,
    ImageHeadData: ImageHeadData,
    ImageItemData: ImageItemData,


    PlotMenuItemData: PlotMenuItemData,
    PlotMenuData: PlotMenuData,
    TalkData: TalkData,
    TextData: TextData,
    PasswordLockData: PasswordLockData,
    // EventData: EventData,
    EventPlotData: EventPlotData,
    EventValueData: EventValueData,
    // ui
    UiCoverData: UiCoverData,
    UiMenuData: UiMenuData,
    UiEnvData: UiEnvData,
    UiFileMgrData: UiFileMgrData,
    // 各种类
    PlotJumpData: PlotJumpData,
    AudioBgStopGlobalData: AudioBgStopGlobalData,
    AudioBgData: AudioBgData,
    AudioEffectData: AudioEffectData,
    AudioAsideData: AudioAsideData,

    EffectRainData: EffectRainData,
    EffectSnowData: EffectSnowData,
    EffectWinData: EffectWinData, // todo 删除
    EffectLeafFallData: EffectLeafFallData,
    EffectFogData: EffectFogData,
    EffectLightData: EffectLightData,
    EffectFireData: EffectFireData,
    EffectSpotFireData: EffectSpotFireData,
    EffectBoomData: EffectBoomData,
    EffectBloodDownData: EffectBloodDownData,
    EffectBloodDripData: EffectBloodDripData,

    VideoPlotData: VideoPlotData,
    ValueJudgeData: ValueJudgeData,
    QTEData: QTEData,
    QTETimerColorStyle: QTETimerColorStyle,
    ActionNone: ActionNone,
    ActionMove: ActionMove,
    ActionFadeIn: ActionFadeIn,
    ActionFadeOut: ActionFadeOut,
    ActionShake: ActionShake,
    ActionScale: ActionScale,
    ActionRotation: ActionRotation,
    ActionBlur: ActionBlur,
    ActionAudioPlay: ActionAudioPlay,
    ActionVideoPlay: ActionVideoPlay,
    //  集合类型
    Action: Action,
    ProjectCfg: ProjectCfg,
};

window.AvgData = AvgData;
// 兼容creator设置为插件
if (typeof module !== 'undefined' && module && module.exports) {
    module.exports = AvgData;
}
